QuickOPC User's Guide and Reference
DAVtq Format Strings
In This Topic

OPC Data Access value/timestamp/quality triples (instances of DAVtq) can be formatted using standard or custom format strings.

Standard and custom format strings are supported by some overloads of the ToString method. For example, you can supply a format string to the ToString(String) and ToString(String, IFormatProvider) methods. Standard and custom format strings are also supported by the .NET Framework composite formatting feature, which is used by some Write and WriteLine methods of the Console and StreamWriter classes, the String.Format method, and the StringBuilder.AppendFormat method. The composite format feature allows you to include the string representation of multiple data items in a single string, to specify field width, and to align values in a field.

Standard DAVtq Format Strings

A standard DAVtq format string has a form of a single alphabetic character called the format specifier. Any DAVtq format string that is not a standard format string is interpreted as a custom DAVtq format string. This includes strings that contain any whitespace before or after the standard format specifier.

The following table describes the standard format strings and displays sample output produced by each format specifier.

Format specifier Name Description  
“f” Full (short) Contains the value, the timestamp and the quality.  
“F” Full (long) Contains the value and its type (full name), the timestamp and the quality.  
“g” General (short) Contains the value when it is present, the timestamp and the quality.  
“G” General (long) Contains the value and its type (just the name) when the value is present, the timestamp and the quality.  

Custom DAVtq Format Strings

You can create a custom DAVtq format string, which consists of one or more custom format specifiers, to define how to format the DAVtq. A custom DAVtq format string is any format string that is not a standard DAVtq format string.

The following table describes the custom format specifiers and displays sample output produced by some of the format specifiers.

Format specifier Name Description  
Hv HasValue Value of the named property.  
Q
Q(format)
Quality Value of the named property, optionally formatted with format.  
T
T(format)
Timestamp Value of the named property, optionally formatted with format.  
Tl
Tl(format)
TimestampLocal Value of the named property, optionally formatted with format.  
V
V(format)
Value Value of the named property, optionally formatted with format.  

Vt
Vt(format)

ValueType Value of the named property, optionally formatted with format.  
\ Escape character Causes the next character to be interpreted as a literal rather than as a custom format specifier.  
'string'
"string"
Literal string delimiter Indicates that the enclosed characters should be copied to the result string unchanged.  
; Section separator Defines sections with separate format.  
Other All other characters The character is copied to the result string unchanged.  

The “;” Section Separator

The semicolon (;) is a conditional format specifier that applies different formatting to a value depending on the condition(s) it fulfills. To produce this behavior, a custom format string can contain up to two or more separated by semicolons. These sections are described in the following table.

Number of sections Description
1 The format string applies to all values.
2 If the VTQ contains (has) a value, section #2 applies.
Otherwise, section #1 applies.
>= 3 Last 2 sections are taken as if there were just 2 sections. The preceding sections are ignored.
See Also